package util;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Writable;

public class ScanMessage implements Writable {

	String msg;
	
	long msgId;
	
	
	public ScanMessage() {
		msg = "";
	}
	
	public ScanMessage(long id, String ms){
		msgId = id;
		msg =ms;
	}
//	public ScanMessage(long id, T ms, Class msgClass) {
//		msgId = id;
//		this.msg = ms;
//		switch(msgClass.getSimpleName()){
//		case "Int":
//			clsId =0;
//		case "Long":
//			clsId =1;
//		case "String":
//			clsId=2;
//		default : throw  new UnsupportedClassVersionError("unsupported message type");
//		}
//		
//	}
	public String getMsg(){
		return msg;
	}
	public long getMsgId(){
		return msgId;
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		msgId = in.readLong();
		msg =   in.readUTF();
		
//		clsId = in.readInt();
//		switch(clsId){
//		case 0 : 
//			msgId = in.readLong();
//			msg = (T) new IntWritable(in.readInt());
//		case 1 : 
//			msgId = in.readLong();
//			msg = (T) new LongWritable(in.readLong());
//		case 2 : 
//			msgId = in.readLong();
//			msg = (T) new DoubleWritable(in.readDouble());
//		case 3 : 
//			msgId = in.readLong();
//			msg = (T) new Text(in.readUTF());
//			default : throw  new UnsupportedClassVersionError("unsupported message type");
//		}
	}

	@Override
	public void write(DataOutput out) throws IOException {
		out.writeLong(msgId);
		out.writeUTF(msg);
		}
		
}
